package com.API.beans;

import com.API.dal.entities.Equipments;
import com.API.dal.providers.EquipmentsProvider;
import org.primefaces.context.RequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Scope("request")
public class EquipmentsBean {

    @Autowired
    EquipmentsProvider equipmentsProvider;

    List<Equipments> equipmentList;
    Equipments equipment;

    public Equipments getEquipment() {
        return equipment;
    }

    public void setEquipment(Equipments equipment) {
        this.equipment = equipment;
    }

    public List<Equipments> getEquipmentList() {
        if (equipmentList == null)
            equipmentList = equipmentsProvider.getEquipments();
        return equipmentList;
    }


    public void addMaterialConsumption(){

    }

    public void addEquipment(){
        final RequestContext context = RequestContext.getCurrentInstance();
        context.execute("addEquipmentsDialog.show()");
    }

    public void saveEquipment(){

    }
    public void editEquipment(){

    }
    public void viewEquipment(){

    }
    public void closeAddDialog(){

    }
    public void closeEditDialog(){

    }

}
